<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 剩余参数
      // ...变量名
      // arr是一个真数组，存的是剩下的实参
      // ...arr只能放在形参位置的最后面
      function getSum(...arr) {
        console.log(arr)
        let c = 0
        arr.forEach((item) => (c += item))
      }
      //   getSum(3, 4, 5, 6) // [3,4,5,6]
      //   getSum(6, 8, 5, 6, 4, 43, 2) // [6, 8, 5, 6, 4, 43, 2]

      function getSum1(a, b, ...arr1) {
        console.log(arr1)
      }
      getSum1(3, 4, 5, 6)
      getSum1(3, 4, 5, 6, 6, 7, 3)
    </script>
  </body>
</html>
